﻿<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <title>KM报表平台登录</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/signin.css" rel="stylesheet">
    <script src="js/jquery/jquery-1.8.1.min.js" type="text/javascript"></script>
    <script src="js/config.js" type="text/javascript"></script>
    <script src="mobile/js/Toast.js" type="text/javascript"></script>
    <link href="css/msgsty.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function () {
            $("#aa").live("click", function () {
                login2();
            });

            $("#a_android").hover(function () {
                $('.chat-tips').show();
                $(".chat-tips").hover(function () {
                    $('.chat-tips').show();
                }, function () {
                    $('.chat-tips').hide();
                });
            }, function () {
                $('.chat-tips').hide();
            });
            $("#usercode").keydown(function (event) {
                if (event.which == 13) {
                    if ($.trim($("#usercode").val()) == "") {
                        showtoast("用户名不能为空！", null, null, null);
                        $("#usercode").focus();
                    } else {
                        $("#userpwd").focus();
                    }
                }
            });
            $("#userpwd").keydown(function (event) {
                if (event.which == 13) {
                    login2();
                }
            });
        });
        //ajax登录方法
        function login2() {
            var ucode = $.trim($("#usercode").val());
            var upwd = $.trim($("#userpwd").val());
            if (ucode == "") {
                showtoast("用户名不能为空！", null, null, null);
                return;
            }
            if (upwd == "") {
                showtoast("密码不能为空！", null, null, null);
                return;
            }
            $("#loading-mask").show();
            $.ajax({
                url: url_path + "/index.aspx",
                type: "POST",
                data: { aciton: 'Login', UserCode: ucode, UserPwd: upwd, LoginType: my_ClientType },
                timeout: 30000,
                dataType: "text",
                success: function (data) {
                    if (data == "user_stop") {
                        $("#loading-mask").hide();
                        alert("该用户已停用，请重新登录！");
                    } else if (data == 'err_text') {
                        showtoast("用户名或密码错误！", null, null, null);
                        $("#loading-mask").hide();
                    } else if (data == 'user_lock') {
                        showtoast("此帐号已经被登录！", null, null, null);
                        $("#loading-mask").hide();
                    } else {
                        var msg = $.trim(data);
                        var orderObj = JSON.parse(msg);
                        for (var i = 0; i < orderObj.length; i++) {
                            //储存到本地
                            localStorage.removeItem("UserCode");
                            localStorage.removeItem("UserName");
                            localStorage.setItem("UserCode", orderObj[i].UserCode);
                            localStorage.setItem("UserName", orderObj[i].UserName);
                        }
                        $("#loading-mask").hide();
                        window.location.href = './index.html';
                    }
                },
                error: function () {
                    $("#loading-mask").hide();
                    showtoast("通讯超时,请检查网络.", null, null, null);
                }
            });
        }
    </script>
</head>
<body>
    <div class="signin">
        <div class="signin-head">
            <span style="font-size: 58px;">KM报表平台</span><br />
            <span>© 2015快速反应V1.0</span>
        </div>
        <form class="form-signin">
        <input id="usercode" type="text" class="form-control" placeholder="用户名" required
            autofocus />
        <input id="userpwd" type="password" class="form-control" placeholder="密码" required />
        <a id="aa" class="btn  btn-lg btn-warning btn-block" href="#">登录</a>
        </form>
        <div style="text-align: center; padding-top: 10px;">
            <span><a href="#">电脑版</a>|<a id="a_android" href="#">android版</a></span>
        </div>
        <div class="chat-tips">
            <i></i>
            <img style="width: 138px; height: 138px;" src="images/1447739891.png" alt="android手机版">
            <br />
            <span>扫我下载手机版！</span></div>
    </div>
    <div id='loading-mask'>
        <div id="loading">
            <div class="loading-indicator">
                <img src="images/0504317.gif" width="48" height="48" style="margin-right: 8px;" />
                <br />
                <span id="loading-msg">正在登录中...</span>
            </div>
        </div>
    </div>
</body>
</html>
